package com.nstar.orderexpress.view
{
	import com.nstar.orderexpress.control.MainMenuClickEvent;
	import com.nstar.orderexpress.model.Model;
	
	import flash.events.MouseEvent;
	
	import mx.containers.Canvas;
	import mx.controls.Button;
	import mx.controls.ButtonBar;
	import mx.events.FlexEvent;
	import mx.events.ItemClickEvent;

	public class MenuViewClass extends Canvas
	{
		public var bbMenus:ButtonBar;
		public var btnBackSearch:Button;
		
		
		private var model:Model = Model.getInstance();
		
		public function MenuViewClass()
		{
			//TODO: implement function
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,init);
		}
		
		private function init(event:FlexEvent):void{
			bbMenus.addEventListener(ItemClickEvent.ITEM_CLICK,mainMenuHandler);
			btnBackSearch.addEventListener(MouseEvent.CLICK,backSearchHandler);
		}
		
		private function backSearchHandler(event:MouseEvent):void{
			model.mainApp.resizeView(null);
		}
		
		//按钮事件处理
		private function mainMenuHandler(event:ItemClickEvent):void{
			var e:MainMenuClickEvent = new MainMenuClickEvent();
			this.dispatchEvent(e);
		}
		
	}
}